<template>
    <div class="w100 f-grow p20">
        <div class="f16 fw5 fam mb20 h-start-center">
            <div class="apply-item-icon mr15"></div>
            自评打分
        </div>
        <a-form-model
            :model="form"
            ref="form"
            :rules="rules"
            :colon="false"
            class="m-form-model"
            labelAlign="left"
            layout="vertical"
            :wrapperCol="{ span: 12 }"
        >
            <a-row :gutter="10">
                <a-col :span="24">
                    <a-form-model-item label="自评表" prop="evaluationId">
                        <a-select :disabled="!isEdit" placeholder="请选择自评表" v-model="form.evaluationId" allowClear>
                            <a-select-option v-for="(item, index) in selfEvaluationList" :value="item.id" :key="index">
                                {{ item.name }}
                            </a-select-option>
                        </a-select>
                    </a-form-model-item>
                </a-col>
            </a-row>
        </a-form-model>
        <Footer
            @save="save"
            @back="back"
            @previousStep="previousStep"
            @nextStep="nextStep"
            :isShowSave="false"
            :isShowSubmit="isShowSubmit"
            :isShowNext="false"
            :isShowPrevious="true"
        ></Footer>
    </div>
</template>

<script>
import mixin from './mixin'
export default {
    mixins: [mixin],
    props: {
        list: {
            type: Array,
        },
        applyNeedData: {},
    },
    data() {
        return {
            isShowSubmit: this.record?.cjzt ? [1].includes(this.record.cjzt) : true,
            selfEvaluationList: [],
            form: {
                evaluationId: null,
            },
            rules: {
                evaluationId: [
                    {
                        trigger: 'blur',
                        message: '该项未填写',
                        required: true,
                    },
                ],
            },
        }
    },
    mounted() {
        setTimeout(() => {
            this.init()
        }, 1000)
    },
    methods: {
        init() {
            this.form.evaluationId = this.record?.evaluationId
            if (Array.isArray(this.applyNeedData.selfEvaluationList)) {
                this.selfEvaluationList = this.applyNeedData.selfEvaluationList
            }
        },
        async saveApi(id) {
            this.Bus.$emit('loadingStateChange', true)
            try {
                //type 1保存 type:2  保存并提交
                let params = { evaluationId: this.form.evaluationId, id, type: 2 }
                let res = await this.applyApi.selfEvaluation(params)
                if (res.code == 200) {
                    this.$message.success(res.message)
                    this.back()
                }
            } catch (e) {
                console.log(e)
            }
            this.Bus.$emit('loadingStateChange', false)
        },
    },
}
</script>

<style lang="scss" scoped></style>
